package com.heima.enu;

public class EnumMethod {
    public static void main(String[] args) {
        //枚举的方法
    //获取枚举项名称String name;
        String name = EnumLie02.SPRING.name();
        System.out.println(name);
        //int ordinal()获取枚举项在枚举类的索引值
        int ordinal = EnumLie02.SPRING.ordinal();
        int ordina2 = EnumLie02.SUMMER.ordinal();
        System.out.println(ordinal);
        System.out.println(ordina2);
        //int Compareto(E o)比较两个枚举项，返回枚举索引差值
        int i = EnumLie02.SPRING.compareTo(EnumLie02.WINTER);
        System.out.println(i);
        //String toString()返回枚举常量名称
        String s = EnumLie02.SPRING.toString();
        System.out.println(s);
        //获取指定类中指定名称枚举值
        EnumLie02 spring = Enum.valueOf(EnumLie02.class, "SPRING");
        System.out.println(spring);
        //返回所以枚举项
        EnumLie02[] values = EnumLie02.values();
        for (EnumLie02 value : values) {
            System.out.println(value);
        }



    }
}
